using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HP :MonoBehaviour
{
    public GameObject Heathy;
    public GameObject MaxHeathy;
    public GameObject Sprint;
    
    protected int maxHeathyNumber;
    protected float maxSprintNumber;
    protected int heathyNumber;
    protected float sprintNumber;
    
    public void SetInitHeathy(int maxHeathy)
    {
        maxHeathyNumber= maxHeathy;
    }

    public void SetInitStrength(float maxSprint)
    {
        maxSprintNumber= maxSprint;
    }
    protected float GetHPPercent(int heathyNumber)
    {
        float percent = (float)heathyNumber / maxHeathyNumber;
        if (percent > 1) percent = 1;
        if (percent < 0) percent = 0;
        return percent;
    }
    protected float GetSprintPercent(float sprintNumber)
    {
        float percent = sprintNumber / maxSprintNumber;
        if (percent > 1) percent = 1;
        if (percent < 0) percent = 0;
        return percent;
    }

    public virtual void ShowNowHP(int heathyNumber)
    {
        
        Heathy.GetComponent<Image>().fillAmount = GetHPPercent(heathyNumber);
    }
    
    public virtual void ShowNowSprintNumber(float SprintNumber)
    {
        Sprint.GetComponent<Image>().fillAmount = GetSprintPercent(SprintNumber);
    }
}
